/**
 * 基本信息
 */
import React from 'react';
import { Form, Input, DatePicker, Radio } from 'antd';
import CityPicker from '@/components/CityPicker';
import FileUpload from '@/components/Custom/FileUpload';
import { FormHeader, FormLayout } from '../../components';
import { requireRule } from './util';
import FieldHidden from './FieldHidden';

export default function ResumeBase({ form }) {
    const { getFieldDecorator } = form;
    return (
        <>
            <FieldHidden field="overseaExperienceFlag" form={form} />
            <FieldHidden field="overseaEducationFlag" form={form} />
            <FormHeader title="个人信息" id="resume-base" />
            <FormLayout type="full">
                <Form.Item label="头像" help="支持 .png、.jpg、.jpeg、.bmp 格式" style={{ marginBottom: 16 }}>
                    {getFieldDecorator('avatarRelation')(
                        <FileUpload
                            isSingle
                            businessCode="SysAvatar"
                            categoryCode="talentAvatarFile"
                            checkFileType="JPG,JPEG,BMP,PNG"
                            checkFileTypeMsg="只能上传 JPG、JPEG、BMP、PNG 格式的文件！"
                        />
                    )}
                </Form.Item>
            </FormLayout>
            <FormLayout type="col2">
                <Form.Item label="证件号码">
                    {getFieldDecorator('talentIdCard', {
                        rules: [
                            ...requireRule('请输入证件号码'),
                            {
                                validator(rule, value, callback) {
                                    const regex = /[\u4e00-\u9fa5]+/g;
                                    if (value && regex.test(value)) {
                                        callback('证件号码不能包含中文字符');
                                    }
                                    callback();
                                }
                            }
                        ]
                    })(<Input placeholder="请输入" />)}
                </Form.Item>
                <Form.Item label="出生年月">
                    {getFieldDecorator('talentBirth', { rules: requireRule('请选择出生日期') })(
                        <DatePicker.MonthPicker format="YYYY-MM" />
                    )}
                </Form.Item>
                <Form.Item label="性别">
                    {getFieldDecorator('talentSex', { rules: requireRule('请输入性别') })(
                        <Radio.Group>
                            <Radio value="1">男</Radio>
                            <Radio value="2">女</Radio>
                        </Radio.Group>
                    )}
                </Form.Item>
                <Form.Item label="参加工作时间">
                    {getFieldDecorator('talentStartWorkTime', { rules: requireRule('请选择参加工作时间') })(
                        <DatePicker.MonthPicker format="YYYY-MM" />
                    )}
                </Form.Item>
                <Form.Item label="国籍/户籍">
                    {getFieldDecorator('talentNativePlace', { rules: requireRule('请选择国籍/户籍') })(
                        <CityPicker valueType="array" showSearch />
                    )}
                </Form.Item>
                <Form.Item label="现居地">
                    {getFieldDecorator('address', { rules: requireRule('请选择现居地') })(
                        <CityPicker valueType="array" showSearch />
                    )}
                </Form.Item>
            </FormLayout>
        </>
    );
}
